package com.yuan.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//@RestControllerAdvice
@ControllerAdvice
public class MyExceptionHandler {


    @ExceptionHandler(value = NullPointerException.class)
    @ResponseBody
    public String doNullPointerException(Exception ex){
        System.out.println("ex = " + ex);
        return "{'status:'501'}";
    }

    @ExceptionHandler(value = ArithmeticException.class)
    public String doArithmeticException(Exception ex){
        System.out.println("ex = " + ex);
        return "/error/error_502.html";
//        return "/files/img3.jpg";
    }

}
